#include <iostream>
#include <cstdio>
#include "Alloc.hpp"
#include <vector>

template <typename Input,typename Pred>
Input Find_if(Input start,Input end,Pred func)
{
    while(start!=end&&!func(*start))
    {
        ++start;
    }
    return start;
}

template <typename Arg,typename Result>
struct Unart_Function
{
    typedef Arg argument_type;
    typedef Result result_type;
};

template <typename Number>
struct even : public Unart_Function<Number,bool>
{
    bool operator() (Number x) const {return (x&1) == 0;}
};

template <typename AdaptablePredicate>
struct Unary_Negate
{
private:
    AdaptablePredicate pred;
public:
    typedef typename AdaptablePredicate::argument_type argument_value;
    typedef typename AdaptablePredicate::result_type result_type;
    Unary_Negate(const AdaptablePredicate& x):pred(x){}
    bool operator() (const argument_value& x)
    {
        return !pred(x);
    }
};

template<typename AdaptablePredicate>
inline Unary_Negate<AdaptablePredicate>
Not1(const AdaptablePredicate& x)
{   
    return Unary_Negate<AdaptablePredicate>(x);
}

using namespace std;
#include <memory>
int main()
{
    vector<int,kriko::allocator<int> > vec{2,3,4,5,6,6};
    auto iter = Find_if(vec.begin(),vec.end(),Not1(even<int>()));
    cout<<*iter<<endl;
    //getchar();
    return 0;
}